package cn.weibo.repository.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import javax.annotation.Resource;

public abstract class BaseHibernateRepository {

    @Resource(name = "hibernateSessionFactory")
    private SessionFactory sessionFactory;

    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    public Session getCurrentSession(){
        return this.sessionFactory.getCurrentSession();
    }

    public void sessionFlush(){
        this.getCurrentSession().flush();
    }
}
